using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Diagnostics;
using System.Data.OleDb;

namespace MaskData
{
	public abstract class MaskElement
	{
		protected readonly ElementType _type;

		public ElementType Type
		{
			get
			{
				return _type;
			}
		}

		public MaskElement(ElementType type)
		{
			_type = type;
		}
		public abstract bool SaveToRow(DataRow row);
		//public abstract OleDbType GetDbType();
	}

	/// <summary>
	/// IntMaskElement
	/// </summary>
	public class IntMaskElement : MaskElement
	{
		private Int32 _value;
		public Int32 Value
		{
			get
			{
				return _value;
			}
			set{
				_value = value;
			}
		}
		public IntMaskElement(IntElementType type, Int32 value)
			: base(type)
		{ 
			_value = value;
		}
		public override bool SaveToRow(DataRow row)
		{
			row[_type.FieldName] = _value;
			return true;
		}
		//public override OleDbType GetDbType()
		//{
		//    return OleDbType.Integer;
		//}
	}

	/// <summary>
	/// StringMaskElement
	/// </summary>
	public class StringMaskElement : MaskElement
	{
		private String _value;
		public String Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
			}
		}
		public StringMaskElement(StringElementType type, String value)
			: base(type)
		{
			_value = value;
		}
		public override bool SaveToRow(DataRow row)
		{
			row[_type.FieldName] = _value;
			return true;
		}
		//public override OleDbType GetDbType()
		//{
		//    return OleDbType.VarChar;
		//}
	}

	/// <summary>
	/// BoolMaskElement
	/// </summary>
	public class BoolMaskElement : MaskElement
	{
		private bool _value;
		public bool Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
			}
		}
		public BoolMaskElement(BoolElementType type, bool value)
			: base(type)
		{
			_value = value;
		}
		public override bool SaveToRow(DataRow row)
		{
			row[_type.FieldName] = _value;
			return true;
		}
		//public override OleDbType GetDbType()
		//{
		//    return OleDbType.Boolean;
		//}
	}

}
